package de.koller.reason;

import de.koller.aframe.util.thread.ICommand;
import de.koller.oceanFramework.tree.Child;
import de.koller.oceanFramework.tree.Sea3X;
import de.koller.reason.engine.ReasonEngine;
import de.koller.reason.render.RRender;
import de.koller.reason.render.state.RGL;

public class ReasonRoot extends Sea3X {
	
	private final RLoop loop = new RLoop( this );
	@Child public final RRender rRender = new RRender();
	@Child public final ReasonEngine engine = new ReasonEngine();
	
	public final RGL rgl = new RGL( this );
	
	private long time = 0;
	
	@Override
	protected void init() {
		super.init();
		
		this.setIgnoreChildRender( true );
	}
	
	@Override
	protected void update( int elapsedTime ) {
		super.update( elapsedTime );
		
		time++;
	}

	@Override
	protected void render( int elapsedTime ) {
		super.render( elapsedTime );
		
		rRender.renderThis( elapsedTime );
	}
	
	public void start() {
		loop.begin();
	}
	
	public void stop() {
		loop.stop();
	}

	public void call( ICommand command ) {
		loop.thread.call( command );
	}

	public long getTime() {
		return time;
	}

}
